﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using WPFExcelReport.Helpers;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TSJHGS02
    {

        public TSJHGS02()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VGSDAT();
            DataContext = MV;
            InitializeComponent();
        }
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            dwData["GSMANDANT"] = app.Mandant;
            dwData["GSART"] = " AND GSART LIKE '%" + ART.Trim() + "%'";
            dwData["GSHANDLNR"] = " AND GSHANDLNR LIKE '%" + DES.Trim() + "%'";
            
            SResult = TMV.QGS08(dwData);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
        } 
        public override void LOADBYAUF()
        {

            if (!IsSaved)
                return;
            if (ORDERNUM.Length < 20)
                return;
            if (ORDERNUM != KEY)
                return;
            dwData = TBMain.NewRow();
            dwData["GSMANDANT"] = app.Mandant;
            dwData["GSART"] = " AND GSART = '" + ORDERNUM.Substring(1, 20) + "'";
            dwData["GSVAR"] = " AND GSVAR = '" + ORDERNUM.Substring(21, 3) + "'";
            SResult = TMV.QGS08(dwData);
            TBTemp = TBMain.Clone();
            TBTemp.Merge(SResult.Tables[0]);
            foreach (DataRow row in TBTemp.Rows)
            {
                dwMaster.ItemArray = row.ItemArray;
            }
            IsSaved = false;
        }
       
    }
}
